# -*- coding: utf-8 -*-
import os
import sys
import win32api

ElevatedArg = "_OK_"

def _elevateSelf():
	"""
	Gain (prompt) for Administrator priveleges
	"""
	if hasattr(sys, "frozen"):
		args = ['"{0}"'.format(a) for a in sys.argv[1:]]
	else:
		args = ['"{0}"'.format(a) for a in sys.argv]

	args.append(ElevatedArg)

	win32api.ShellExecute(0,
						  "runas",
						  sys.executable,
						  ' '.join(args),
						  os.getcwd(),
						  0
						  )

def elevateSelf():
	if ElevatedArg not in sys.argv:
		_elevateSelf()
		sys.exit(1)
